package com.project.util;

import lombok.Data;

@Data
public class R<D> {
    private Integer code;
    private String msg;
    private D d;
    private R(Integer code, String msg, D d ){
        this.code = code;
        this.msg = msg;
        this.d = d;
    }
    public static R success( String msg ){
        return new R(200, msg, null);
    }
    public static R success(){
        return new R(200, "成功", null);
    }
    public static R fail( String msg ){
        return new R(400, msg, null);
    }
    public static R fail(  ){
        return new R(400, "失败", null);
    }
    public R setData( D d ){
        this.d = d;
        return this;
    }
    public R setMsg( String msg ){
        this.msg = msg;
        return this;
    }
    public R setCode( Integer code ){
        this.code = code;
        return this;
    }
}
